package com.hkts.management.unattended.poundroom.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hkts.management.unattended.poundroom.entity.YbMutualInventoryclass;
import com.hkts.management.unattended.poundroom.entity.YbMutualPovouch;
import com.hkts.management.unattended.poundroom.mapper.YbMutualInventoryclassMapper;
import com.hkts.management.unattended.poundroom.service.IYbMutualInventoryclassService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zy
 * @since 2022-03-20
 */
@Service
@Transactional
public class YbMutualInventoryclassServiceImpl extends ServiceImpl<YbMutualInventoryclassMapper, YbMutualInventoryclass> implements IYbMutualInventoryclassService {


    @Autowired
    private YbMutualInventoryclassMapper ybMutualInventoryclassMapper;

    @Override
    public IPage<YbMutualInventoryclass> selectPage(Page<YbMutualInventoryclass> page, YbMutualInventoryclass ybMutualInventoryclass) {
        QueryWrapper<YbMutualInventoryclass> query = Wrappers.query();
        return ybMutualInventoryclassMapper.selectPage(page, query);
    }


    @Override
    public List<YbMutualInventoryclass> selectList(YbMutualInventoryclass ybMutualInventoryclass) {
        QueryWrapper<YbMutualInventoryclass> query = Wrappers.query();
        return ybMutualInventoryclassMapper.selectList(query);
    }
    public LocalDateTime getLastUpdateTime(){
        QueryWrapper<YbMutualInventoryclass> query = Wrappers.query();
        query.lambda().orderByDesc(YbMutualInventoryclass::getDoptTime);
        query.last("limit 1");
        List<YbMutualInventoryclass> ybMutualCompanies=ybMutualInventoryclassMapper.selectList(query);
        return ybMutualCompanies.size()>0?ybMutualCompanies.get(0).getDoptTime():null;
    }
    public void mysqlInsertOrUpdateBath(List<YbMutualInventoryclass> ybMutualCompanies){
        ybMutualInventoryclassMapper.mysqlInsertOrUpdateBath(ybMutualCompanies);
    }



}
